using System;
using Android.App;
using System.ComponentModel;
using Granite.Metadata;
using Android.Widget;
using System.Collections.Generic;

namespace Granite.Axml
{
	/// <summary>
	/// This is an activity that is designed to work with the NavigationViewModel.
	/// </summary>
	/// <typeparam name="T"></typeparam>
	public abstract class NavigationActivity<T> : Activity where T : NavigationViewModel, new()
	{
		static T s_ViewModel;

		public NavigationActivity()
		{
			if (s_ViewModel == null)
				s_ViewModel = OnCreateViewModel();
		}

		protected virtual T OnCreateViewModel()
		{
			return new T();
		}

		public T ViewModel
		{
			get { return s_ViewModel; }
		}

		protected override void OnResume()
		{
			base.OnResume();
			ViewModel.CurrentActivity = this;
		}

		protected override void OnSaveInstanceState(Android.OS.Bundle outState)
		{
			base.OnSaveInstanceState(outState);
			//Called to retrieve per-instance state from an activity before being killed so that the state can be restored in onCreate(Bundle) or onRestoreInstanceState(Bundle) (the Bundle populated by this method will be passed to both). 
		}
	}

}


